package active.chainofresponsibility;

public abstract class AbstractLogger {
    public static final int INFO = 1;
    public static final int DEBUG = 2;
    public static final int ERROR = 3;

    protected int level;
    protected AbstractLogger abstractLogger;

    public AbstractLogger(int level) {
        this.level = level;
    }

    public void setNextLogger(AbstractLogger abstractLogger) {
        this.abstractLogger = abstractLogger;
    }

    public void logMessage(int level, String message) {
        if (this.level <= level) {
            write(message);
        }
        if (abstractLogger != null) {
            abstractLogger.logMessage(level, message);
        }
    }

    public abstract void write(String message);

}
